import { IndexDto, ShowDto } from '@libs/common/dto';
import { ApiProperty, PartialType } from '@nestjs/swagger';
import { IsNotEmpty } from 'class-validator';
import { FindOptionsWhere } from 'typeorm';

import {
  PointsWait,
  PointsWaitType,
  Status,
} from '../entities/points-wait.entity';

export class IndexPointsWaitDto extends IndexDto<PointsWait> {}

export class ShowPointsWaitDto extends ShowDto {}

export class CreatePointsWaitDto {
  @ApiProperty({ description: '用户名' })
  @IsNotEmpty({ message: '用户名不能为空' })
  userName: string;

  @ApiProperty({ description: '用户ID' })
  @IsNotEmpty({ message: '用户ID不能为空' })
  userId: string;

  @ApiProperty({ description: '钉钉用户ID' })
  @IsNotEmpty({ message: '钉钉用户ID不能为空' })
  dingId: string;

  @ApiProperty({ description: '部门ID' })
  @IsNotEmpty({ message: '部门ID不能为空' })
  departmentId: string;

  @ApiProperty({ description: '部门名' })
  @IsNotEmpty({ message: '部门名不能为空' })
  departmentName: string;

  @ApiProperty({ description: '积分' })
  @IsNotEmpty({ message: '积分不能为空' })
  points: number;

  @ApiProperty({ type: 'enum', description: '类型' })
  type: (typeof PointsWaitType)[number];

  @ApiProperty({ description: '审核状态，0：未发放，1：已发放', default: 0 })
  status?: (typeof Status)[number] = 0;

  @ApiProperty({ description: '审核人', nullable: true })
  approverName?: string;

  @ApiProperty({ description: '审核ID', nullable: true })
  approverId?: string;
}

export class UpdatePointsWaitDto extends PartialType(CreatePointsWaitDto) {
  @ApiProperty()
  @IsNotEmpty({ message: 'id 不能为空' })
  id: string;
}

export class FindPointsWaitDto extends PartialType(CreatePointsWaitDto) {
  id?: FindOptionsWhere<PointsWait>['id'];
}
export class SendPointsWaitDto {
  desc: string;
  type: (typeof PointsWaitType)[number];
  ids?: string[];
  departmentId?: string;
}
